package utils.servicedown;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

import utils.Common;

/**
 * Created by dllo on 15/11/25.
 */
public class MyDownReceiver  extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equals(Common.ACTION_DOWNLOAD_PROGRESS)) {
//            int pro = intent.getExtras().getInt("progress");
//            progBar.setProgress(pro);
        }
        else
        if(action.equals(Common.ACTION_DOWNLOAD_SUCCESS)){
            Toast.makeText(context, "下载成功", Toast.LENGTH_SHORT).show();
//            final File f =(File) intent.getExtras().getSerializable("file");
//            btnOpen.setVisibility(View.VISIBLE);
//            textView.setText("文件已保存在：" + f.getAbsolutePath());
//            btnOpen.setOnClickListener(new View.OnClickListener() {
//
//                @Override
//                public void onClick(View v) {
//                    openFile(f);
//                }
//            });
        }
        else if(action.equals(Common.ACTION_DOWNLOAD_FAIL))
        {
            //textView.setText("文件下载失败");
            Toast.makeText(context, "下载失败", Toast.LENGTH_SHORT).show();
        }
    }

    }

